package java_08;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class java_01 {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new FileReader("sort.txt"));
		ArrayList<String> arr=new ArrayList<>();
		String ch;
		while((ch=bf.readLine())!=null){
			arr.add(ch);
		}
		bf.close();
		Collections.sort(arr);
		System.out.println(arr);
		BufferedWriter bw=new BufferedWriter(new FileWriter("sort.txt"));
		for (String line : arr) {
			bw.write(line);
			bw.newLine(); 
		}
		bw.close();
	}
}
